package apps.AfterDlcs.afterDlcsBL.city;

import apps.AfterDlcs.AfterDlcs;
import apps.AfterDlcs.afterDlcsBL.Keys;
import backs.dataBase.DBNormal;
import backs.tools.Tools;

import java.util.HashMap;
import java.util.Map;

public class City
{
    public static Map<String,City> cityMap=new HashMap<>();
    int worldID,cityID;
    public City(int worldID,int cityID)
    {
        this.worldID=worldID;
        this.cityID=cityID;
    }


    public static City getCity(int worldID,int cityID)
    {
        String key=worldID+"_"+cityID;
        if(!cityMap.containsKey(key))
        {
            cityMap.put(key,new City(worldID,cityID));
        }
        return cityMap.get(key);
    }

    public String getCityValue(String key)
    {
        return getCityValue(key,null,false);
    }

    public String getCityValue(String key,String deafultKey,boolean reset)
    {
        return DBNormal.getValue(AfterDlcs.dbName,worldID,"city_"+cityID+key,deafultKey,reset);
    }

    public int getLocationX()
    {
        return Integer.parseInt(getCityValue(Keys.LOCATION_X, Tools.getRandom(1,99999999)+"",true));
    }

    public int getLocationY()
    {
        return Integer.parseInt(getCityValue(Keys.LOCATION_Y, Tools.getRandom(1,99999999)+"",true));
    }
}
